
#include "grass.h"

void Grass_Init(Grass* grass, Vector3f position, Vector3f normal, GRASS_TYPE type)
{
	Color c;
	char* filename;
	Camera cam;
	Color_Init(&c,32,48,128,255);
	Camera_Init(&cam);
	grass->position = position;
	grass->normal = normal;
	grass->type = type;
	grass->sprite = (Sprite*) malloc(sizeof(Sprite));
	switch (grass->type)
	{
	case GRASS_TYPE_DESERT_1:
		if(textureId[0] == 0)
		{
			Sprite_InitBillboard(grass->sprite,"desert_1.png",&grass->position,&c,&cam);
			textureId[0] = grass->sprite->textureId;
		}
		else
			Sprite_InitBillboardFromTextureId(grass->sprite,textureId[0],&grass->position,&c,&cam);
		break;
	case GRASS_TYPE_DESERT_2:
		if(textureId[1] == 0)
		{
			Sprite_InitBillboard(grass->sprite,"desert_2.png",&grass->position,&c,&cam);
			textureId[1] = grass->sprite->textureId;
		}
		else
			Sprite_InitBillboardFromTextureId(grass->sprite,textureId[1],&grass->position,&c,&cam);
		break;
	case GRASS_TYPE_DESERT_3:
		if(textureId[2] == 0)
		{
			Sprite_InitBillboard(grass->sprite,"desert_3.png",&grass->position,&c,&cam);
			textureId[2] = grass->sprite->textureId;
		}
		else
			Sprite_InitBillboardFromTextureId(grass->sprite,textureId[2],&grass->position,&c,&cam);
		break;
	case GRASS_TYPE_DESERT_4:
		if(textureId[3] == 0)
		{
			Sprite_InitBillboard(grass->sprite,"desert_4.png",&grass->position,&c,&cam);
			textureId[3] = grass->sprite->textureId;
		}
		else
			Sprite_InitBillboardFromTextureId(grass->sprite,textureId[3],&grass->position,&c,&cam);
		break;
	case GRASS_TYPE_DESERT_5:
		if(textureId[4] == 0)
		{
			Sprite_InitBillboard(grass->sprite,"desert_5.png",&grass->position,&c,&cam);
			textureId[4] = grass->sprite->textureId;
		}
		else
			Sprite_InitBillboardFromTextureId(grass->sprite,textureId[4],&grass->position,&c,&cam);
		break;
	};
	

}

void Grass_Draw(Grass* grass, const Camera* camera)
{
	Sprite_Draw(grass->sprite,camera,1.0f);
}

void Grass_Destroy(Grass* grass)
{
	Sprite_Destroy(grass->sprite);
}